package com.crazymakercircle.mutithread.basic.create;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CreateDemo {

    public static final int MAX_TURN = 5;
    static int threadNo = 1;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = null;
        //方法一：使用Thread子类创建和启动线程
        for (int i = 0; i < 2; i++) {
            thread = new DemoThread();
            thread.start();
        }
        System.out.println("hello");
        log.info(" 运行结束.");
    }

    static class DemoThread extends Thread {

        public DemoThread() {
            super("Mall-" + threadNo++);
        }

        public void run() {
            for (int i = 1; i < MAX_TURN; i++) {
                log.info("轮次：" + i);
            }
            log.info("运行结束.");
        }
    }
}